#include <graphics.h>
#include "snake_body.h"
#include "settings.h"

void Snake_body::move(void)
{
	if (direction_next == UP)
		y -= LENGTH;
	else if (direction_next == DOWN)
		y += LENGTH;
	else if (direction_next == LEFT)
		x -= LENGTH;
	else if (direction_next == RIGHT)
		x += LENGTH;
	direction_now = direction_next;
}

void Snake_body::move(key_t direction_now)
{
	if (direction_now == UP)
		y -= LENGTH;
	else if (direction_now == DOWN)
		y += LENGTH;
	else if (direction_now == LEFT)
		x -= LENGTH;
	else if (direction_now == RIGHT)
		x += LENGTH;
}

void Snake_body::draw(void)
{
	setfillcolor(WHITE);
	bar(x, y, x + LENGTH, y + LENGTH);
}

void Snake_body::redirect(class Snake_body &body_previous)
{
	direction_next = body_previous.direction_now;
}